﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Globalization;
using Microsoft.Win32;
using System.IO;
using System.Diagnostics;

public partial class Whir_System_Module_Config_SystemInfo : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        RoleHelper.IsLogin();    //登录判断
        if (!IsPostBack)
        {
            BindData();
        }
    }

    private void BindData()
    {
        lbServerName.Text = "http://" + HttpContext.Current.Request.Url.Host + HttpContext.Current.Request.ApplicationPath;
        lbIp.Text = Request.ServerVariables["LOCAl_ADDR"];
        lbDomain.Text = Request.ServerVariables["SERVER_NAME"].ToString();
        lbPort.Text = Request.ServerVariables["Server_Port"].ToString();
        lbPhPath.Text = Request.PhysicalApplicationPath;
        lbOperat.Text = Environment.OSVersion.ToString();
        lbSystemPath.Text = Environment.SystemDirectory.ToString();
        lbTimeOut.Text = (Server.ScriptTimeout / 1000).ToString() + "秒";
        lbLan.Text = CultureInfo.InstalledUICulture.EnglishName;
        lbAspnetVer.Text = string.Concat(new object[] { Environment.Version.Major, ".", Environment.Version.Minor, Environment.Version.Build, ".", Environment.Version.Revision });
        lbCurrentTime.Text = DateTime.Now.ToString();

        RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Version Vector");
        lbIEVer.Text = key.GetValue("IE", "未检测到").ToString();
        lbServerLastStartToNow.Text = ((Environment.TickCount / 0x3e8) / 60).ToString() + "分钟";

        string[] achDrives = Directory.GetLogicalDrives();
        for (int i = 0; i < Directory.GetLogicalDrives().Length - 1; i++)
        {
            lbLogicDriver.Text = lbLogicDriver.Text + achDrives[i].ToString();
        }

        //ManagementClass diskClass = new ManagementClass("NUMBER_OF_PROCESSORS");
        lbCpuNum.Text = Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS").ToString();
        lbCpuType.Text = Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER").ToString();
        lbMemory.Text = (Environment.WorkingSet / 1024).ToString() + "M";
        lbMemoryPro.Text = ((Double)GC.GetTotalMemory(false) / 1048576).ToString("N2") + "M";
        lbMemoryNet.Text = ((Double)Process.GetCurrentProcess().WorkingSet64 / 1048576).ToString("N2") + "M";
        lbCpuNet.Text = ((TimeSpan)Process.GetCurrentProcess().TotalProcessorTime).TotalSeconds.ToString("N0");
        lbSessionNum.Text = Session.Contents.Count.ToString();
        lbSession.Text = Session.Contents.SessionID;
        lbUser.Text = Environment.UserName;
    }
}
